/**
 * 策略模式 + 简单工厂模式实现
 * @author shuang
 * @date 2021/12/13 0:07
 */
public class CashContext {

    private CashSuper cs;

    public CashContext(String type) {
        switch (type) {
            case "正常收费":
                cs = new CashNormal();
                break;
            case "打 8 折":
                cs = new CashRebate("0.8");
                break;
            case "满 300 返 100":
                cs = new CashReturn("300", "100");
                break;
            default:
                break;
        }
    }

    public double getResult(double money) {
        return cs.acceptCash(money);
    }
}

